package com.zjk.file.controller;

import com.zjk.Result;
import com.zjk.file.config.FastDFSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author: gfk
 * @create: 2022/10/18
 * @Description:
 * @FileName: FastDFSController
 * @History:
 * @自定义内容：
 */
@RestController
@RequestMapping("/file/upload")
public class FastDFSController {

    @Autowired
    private FastDFSClient fastDFSClient;

    @PostMapping("/fast")
    public Result fastUpload(@RequestParam MultipartFile file){
        String url = fastDFSClient.upload(file);
        if (url!=null){
            return new Result(true,100,url);
        }
        return Result.FAIL();
    }
}
